package com.start.workflow.act;

import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.activiti.engine.repository.ProcessDefinition;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@Data
 @Schema(name="StartDeployHistory", description = "流程定义历史记录")
public class StartDeployHistory {
     @Schema(name="流程定义id")
    private String defId;
     @Schema(name="流程定义key")
    private String defKey;
     @Schema(name="流程定义名称")
    private String defName;
     @Schema(name="流程定义版本")
    private int defVersion;
     @Schema(name="流程类别")
    private String defCategory;
     @Schema(name="流程发布id")
    private String defDeploymentId;
     @Schema(name="引擎版本")
    private String engineVersion;

    public StartDeployHistory() {

    }

    public StartDeployHistory(ProcessDefinition definition) {
        defId = definition.getId();
        defKey = definition.getKey();
        defName = definition.getName();
        defVersion = definition.getVersion();
        defCategory = definition.getCategory();
        defDeploymentId = definition.getDeploymentId();
        engineVersion = definition.getEngineVersion();
    }

    public static List<StartDeployHistory> create(Collection<ProcessDefinition> definitions) {
        return definitions.stream().map(StartDeployHistory::new).collect(Collectors.toList());
    }
}
